package com.douqu.game.core.config.map;

import com.douqu.game.core.config.common.GoodsData;
import com.douqu.game.core.entity.GameObject;
import com.douqu.game.core.util.LoadUtils;
import com.douqu.game.core.util.LogUtils;

/**
 * @author: Gavin.
 * Description:
 * Date: 2018/5/5 0005 上午 11:58
 * Huan Yu Copyright (c) 2017 All Rights Reserved.
 */
public class WorldMapTaskBoxConfig extends GameObject{

    public String boxIcon;
    /**
     * 组id
     */
    public int group;

    /**
     * 需要数量
     */
    public int needCount;

    /**
     * 奖励
     */
    public GoodsData[] reward;

    @Override
    public boolean check() {
        if(reward == null){
            LogUtils.error("worldMapTaskBox check reward is null -> id:" + id);
            return false;
        }
        return super.check();
    }

    @Override
    public boolean setVariable(String key, String value) {
        if("reward".equals(key)){
            reward = LoadUtils.loadGoodDataToArray(key, value);
            return LoadUtils.checkGoods(reward, this.getClass(), key, id);
        }
        else
            return super.setVariable(key, value);
    }



    @Override
    public String toString() {
        return "WorldMapTaskBoxConfig{" +
                "group=" + group +
                ", need_count=" + needCount +
                ", reward=" + reward +
                '}';
    }
}
